home *** CD-ROM | disk | FTP | other *** search
/ Acorn RISC PD-CD 1 / Acorn RISC PD-CD 1.iso / languages / perl / examples / titlecat < prev    next >
Encoding:
Text File  |  1991-02-21  |  426 b   |  23 lines

  1. # Concatenate a set of files, with a header at the start of
  2. # each, and with each file line numbered.
  3.  
  4.  
  5. # First, expand wildcards in the argument list...
  6. # (This can be used as standard bolt-in code for other scripts)
  7.  
  8. foreach (@ARGV)
  9. {
  10.     push(@a,<${_}>);
  11. }
  12.  
  13. @ARGV = @a;
  14.  
  15. # OK, now cat the files
  16.  
  17. while (<>)
  18. {
  19.     print "\n", $ARGV, "\n", '-' x length($ARGV), "\n" if ($. == 1);
  20.     printf "%5d %s", $., $_;
  21.     close(ARGV) if (eof);
  22. }
  23.